TitleGridPanel = function(){
	var data = [
		{title:'主题信息1',tid:1},
		{title:'主题信息2',tid:2},
		{title:'主题信息3',tid:3},
		{title:'主题信息4',tid:4},
		{title:'主题信息5',tid:5}
	];
	var url = __ctxPath+'/back/article/findtitleinfo.html';
	var store = new Ext.data.JsonStore(
		{
//			data:data,
			totalProperty:'totalCount',
			root:'data',
			url:url,
			autoLoad:true,
			fields:['title','tid','tdatetime','tusername','tuserid','tnote']
		}
	);
	var editOnlyOneInfo = function(grid, rowIndex, colIndex){
		var rec = store.getAt(rowIndex);
        var win = new AreaWindow('修改信息');
		win.setIconClass('edit');
		win.show();
		win.load(rec);
		win.on('submit',function(win,form,data){
			form.getForm().submit(
				{
					url:__ctxPath+'/back/article/updatetitleinfo.html',
					method:'POST',
					success:function(form,action){
						if(action.result.success){
							var d = rec.data;
							for(var i in d){
								rec.set(i,data[i]);
							}
							rec.commit();
							win.close();
							Ext.MessageBox.alert('系统提示','修改成功!');
						
						}else{
							Ext.MessageBox.alert('系统提示','修改失败!');
						}	
					},
					failure:function(form,action){
						Ext.MessageBox.alert('系统提示','网络原因 修改失败');
					}
				}
			);
		});
	};
	var deleteOnlyOneInfo = function(grid, rowIndex, colIndex){
		var rec = store.getAt(rowIndex);
        Ext.Msg.confirm('系统提示','是否确定删除选择的数据',function(btn){
			if(btn=='yes'){
				Ext.Ajax.request(
					{
						url:__ctxPath+'/back/article/deletetitleinfo.html',
						method:'POST',
						params:{ids:rec.get('tid')},
						success:function(resp,option){
							var result = Ext.decode(resp.responseText);
							if(result.success){
								store.remove(rec);
								grid.getView().refresh();
								Ext.MessageBox.alert('系统提示','删除成功');	
							}else{
								Ext.MessageBox.alert('系统提示','删除失败');
							}
						},
						failure:function(resp,option){
							Ext.MessageBox.alert('系统提示','网络原因,删除失败');
						}
					}
				);
			}
		});
	};
	var cm = [
		{
            xtype: 'actioncolumn',
            header:'操作',
            width: 50,
            items: [
            {
                iconCls :'edit',
                tooltip: '编辑栏目',
                handler: editOnlyOneInfo
            }, {
                iconCls :'delete',
                tooltip: '删除栏目',
                handler: deleteOnlyOneInfo
            }]
        },
		{header:"栏目名称",dataIndex:"title",width:120},
		{header:"录入时间",dataIndex:"tdatetime",width:120},
		{header:"录入人",dataIndex:"tusername",width:100}
	];
	var searchbox = new Ext.form.TwinTriggerField({
	   	validationEvent:false,
	   	validateOnBlur:false,
	   	trigger1Class:'x-form-clear-trigger',
	   	trigger2Class:'x-form-search-trigger',
	   	hideTrigger1:true,
	   	width:300,
	   	hasSearch : false,
       	paramName : 'query',
       	listeners:{'specialkey':function(f, e){
       		if(e.getKey() == e.ENTER){
				this.onTrigger2Click();
			}
	   	}},
       	onTrigger1Click : function(){
			if(this.hasSearch){
				this.el.dom.value = '';
				this.triggers[0].hide();
				this.hasSearch = false;
				this.focus();
			}
		},
		onTrigger2Click : function(){
			var v = this.getRawValue();
			var _url='quickfinddict1.html';
			
			var _obj = {start:0,limit:20,condition:v};
			var _store=articlestore;
			_store.proxy.setUrl(_url,true);
			_store.baseParams = _obj;
			_store.load({params:_obj});
			
			this.hasSearch = true;
			this.triggers[0].show();
			this.focus();
		}			
	});
	var tbar = [
		{
			text:'新增标题',
			iconCls:'db-icn-add',
			handler:function(){
				var me = this;
				var win = new TitleWindow();
				win.show();
				win.on('submit',function(win,form,data){
					form.getForm().submit(
						{
							url:__ctxPath+'/back/article/addtitleinfo.html',
							method:'POST',
							success:function(form,action){
								if(action.result.success){
									var rec = new Ext.data.Record(data);
									rec.set('tid',action.result.aid);
									rec.commit();
									store.insert(0,rec);
									Ext.MessageBox.alert('系统提示','添加成功!');
									win.close();
									grid.getView().refresh();
								}else{
									Ext.MessageBox.alert('系统提示','添加失败!');
								}	
							},
							failure:function(form,action){
								Ext.MessageBox.alert('系统提示','网络原因 添加失败');
							}
						}
					);
				});
			},
			scope:this
		},'-',searchbox
	];
	var bbar = [
		new Ext.PagingToolbar(
			{
				 store: store,       // grid and PagingToolbar using same store
        		 displayInfo: true,
        		 pageSize: 20,
        		 plugins: new Ext.ux.ProgressBarPager({progBarWidth:400})
			}
		)
	];
	var grid = new Ext.grid.GridPanel(
		{
			store:store,
			tbar:tbar,
			bbar:bbar,
			width:500,
			height:400,
			columns:cm
		}
	);
	var config = {
		title:'标题信息',
		
		iconCls:'tab',
		id:'TitleGridPanel',
		layout:"fit",
		width:500,
		height:400,
		items:[grid]
	};
	TitleGridPanel.superclass.constructor.call(this,config);
}
Ext.extend(TitleGridPanel,Ext.Panel);